package com.atguigu;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Properties;

/**
 * @Author lizhenchao@atguigu.cn
 * @Date 2021/2/9 15:53
 */
public class JdbcDemo1 {
    public static void main(String[] args) throws SQLException {
        String mysqlUrl = "jdbc:mysql://hadoop162:3306/test";
        final Properties props = new Properties();
        props.setProperty("user", "root");
        props.setProperty("password", "aaaaaa");
        final Connection conn = DriverManager.getConnection(mysqlUrl, props);
        final PreparedStatement ps = conn.prepareStatement("insert into stu(?, ?)values(?,?)");
        ps.setObject(1, "`id`");
        ps.setObject(2, "`name`");
        ps.setString(3, "3");
        ps.setString(4, "c");
        ps.execute();
    }
}
